package com.googlecode.scup.grammar.grammarspart;

import java.util.List;

public class Rule {
    private Symbol base = null;
    private List<Production> productions = null;

    public Rule(Symbol base, List<Production> productions) {
        this.base = base;
        this.productions = productions;
    }

    public Symbol getBase() {
        return base;
    }

    public List<Production> getProductions() {
        return productions;
    }

    public void addProduction (Production production) {
    	productions.add(production);
    }

    public String toString() {
        StringBuilder result = new StringBuilder();
        result.append(base.getName());
        result.append(" ->");
        result.append(productions.get(0));
        for (int i = 1; i < productions.size(); ++i) {
            result.append(" |");
            result.append(productions.get(i));
        }
        return result.toString();
    }

//    public boolean equals() {
//        //some code
//    }
}
